import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace AccountBalanceApi {
  /** 会员余额信息 */
  export interface AccountBalance {
    id: number; // 主键
    memberId: number; // 会员id
    totalBalance: number; // 总余额
    cashBalance: number; // 现金金额
    giftBalance: number; // 赠送余额
    lastUpdate: string | Dayjs; // 最后更新时间
  }
}

/** 查询会员余额分页 */
export function getAccountBalancePage(params: PageParam) {
  return requestClient.get<PageResult<AccountBalanceApi.AccountBalance>>('/reservation/account-balance/page', { params });
}

/** 查询会员余额详情 */
export function getAccountBalance(id: number) {
  return requestClient.get<AccountBalanceApi.AccountBalance>(`/reservation/account-balance/get?id=${id}`);
}

/** 新增会员余额 */
export function createAccountBalance(data: AccountBalanceApi.AccountBalance) {
  return requestClient.post('/reservation/account-balance/create', data);
}

/** 修改会员余额 */
export function updateAccountBalance(data: AccountBalanceApi.AccountBalance) {
  return requestClient.put('/reservation/account-balance/update', data);
}

/** 删除会员余额 */
export function deleteAccountBalance(id: number) {
  return requestClient.delete(`/reservation/account-balance/delete?id=${id}`);
}

/** 导出会员余额 */
export function exportAccountBalance(params: any) {
  return requestClient.download('/reservation/account-balance/export-excel', params);
}

